package vista;
import com.cloudgarden.layout.AnchorConstraint;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class DlgGestionarEmpleados extends javax.swing.JDialog {

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	private JButton btSalir;
	private JScrollPane jScrollPane1;
	private JButton btBuscar;
	private JButton btVer;
	private JLabel lblCedula;
	private JTextField txtCedula;
	private JTable tbEmpleados;
	private JButton btIncluir;
	private JButton btModificar;
	private JButton btEliminar;

	/**
	* Auto-generated main method to display this JDialog
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				JFrame frame = new JFrame();
				DlgGestionarEmpleados inst = new DlgGestionarEmpleados(frame);
				inst.setVisible(true);
			}
		});
	}
	
	public DlgGestionarEmpleados(JFrame frame) {
		super(frame);
		initGUI();
	}
	
	private void initGUI() {
		try {
			{
				getContentPane().setLayout(null);
				this.setTitle("Gestionar Empleado");
				{
					btSalir = new JButton();
					getContentPane().add(btSalir);
					btSalir.setText("Salir");
					btSalir.setIcon(new ImageIcon(getClass().getClassLoader().getResource("iconos/Salir.gif")));
					btSalir.setHorizontalTextPosition(JButton.CENTER);
					btSalir.setVerticalTextPosition(JButton.BOTTOM);
					btSalir.setBounds(451, 376, 79, 40);
				}
				{
					btEliminar = new JButton();
					getContentPane().add(btEliminar);
					btEliminar.setText("Eliminar");
					btEliminar.setIcon(new ImageIcon(getClass().getClassLoader().getResource("iconos/eliminar.PNG")));
					btEliminar.setHorizontalTextPosition(JButton.CENTER);
					btEliminar.setVerticalTextPosition(JButton.BOTTOM);
					btEliminar.setBounds(240, 376, 90, 40);
				}
				{
					btModificar = new JButton();
					getContentPane().add(btModificar);
					btModificar.setText("Modificar");
					btModificar.setIcon(new ImageIcon(getClass().getClassLoader().getResource("iconos/Modificar.png")));
					btModificar.setHorizontalTextPosition(JButton.CENTER);
					btModificar.setVerticalTextPosition(JButton.BOTTOM);
					btModificar.setBounds(127, 375, 90, 40);
				}
				{
					btIncluir = new JButton();
					getContentPane().add(btIncluir);
					btIncluir.setText("Incluir");
					btIncluir.setIcon(new ImageIcon(getClass().getClassLoader().getResource("iconos/incluir.PNG")));
					btIncluir.setHorizontalTextPosition(JButton.CENTER);
					btIncluir.setVerticalTextPosition(JButton.BOTTOM);
					btIncluir.setBounds(31, 375, 79, 40);
				}
				{
					jScrollPane1 = new JScrollPane();
					getContentPane().add(jScrollPane1);
					jScrollPane1.setBounds(92, 110, 382, 177);
					{
						TableModel tbClientesModel = 
							new DefaultTableModel(
									new String[][] { { "One", "Two" }, { "Three", "Four" } },
									new String[] { "Column 1", "Column 2" });
						tbEmpleados = new JTable();
						jScrollPane1.setViewportView(tbEmpleados);
						tbEmpleados.setModel(tbClientesModel);
						tbEmpleados.setBounds(66, 83, 352, 170);
					}
				}
				{
					btBuscar = new JButton();
					getContentPane().add(btBuscar);
					btBuscar.setIcon(new ImageIcon(getClass().getClassLoader().getResource("iconos/buscar.PNG")));
					btBuscar.setBounds(367, 29, 41, 27);
				}
				{
					txtCedula = new JTextField();
					getContentPane().add(txtCedula);
					txtCedula.setBounds(201, 31, 154, 28);
				}
				{
					lblCedula = new JLabel();
					getContentPane().add(lblCedula);
					lblCedula.setText("Cedula:");
					lblCedula.setFont(new java.awt.Font("Tahoma",1,11));
					lblCedula.setBounds(140, 37, 49, 14);
				}
				{
					btVer = new JButton();
					getContentPane().add(btVer);
					btVer.setText("Ver");
					btVer.setIcon(new ImageIcon(getClass().getClassLoader().getResource("iconos/Ver.png")));
					btVer.setVerticalTextPosition(JButton.BOTTOM);
					btVer.setHorizontalTextPosition(JButton.CENTER);
					btVer.setBounds(350, 376, 79, 40);
				}
				{
					lblSeleccionarCliente = new JLabel();
					getContentPane().add(lblSeleccionarCliente, new AnchorConstraint(143, 611, 236, 374, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
					lblSeleccionarCliente.setText("Seleccionar Empleado:");
					lblSeleccionarCliente.setFont(new java.awt.Font("Tahoma",1,11));
					lblSeleccionarCliente.setBounds(222, 64, 138, 40);
				}
			}
			this.setSize(572, 472);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	DlgGestionarEmpleados dgemp=this;
	private JLabel lblSeleccionarCliente;
	public void mostrar(JFrame frame) {
		
		setLocationRelativeTo(null);
		setVisible(true);
		
		btVer.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				DlgEmpleado demp= new DlgEmpleado(dgemp);
				   if(tbEmpleados.getSelectedRow()!=-1)
				      demp.mostrar(dgemp);
				   else
					   JOptionPane.showMessageDialog(dgemp, "Debe Seleccionar un Cliente", "Seleccionar",JOptionPane.ERROR_MESSAGE);
			}
		});
	
		
		btSalir.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				dgemp.dispose();
			}
		});
	}

}
